<html>
<head>
	<title>Tester</title>
	
	<!-- <link rel="stylesheet" type="text/css" href="css/core.css"> -->
	<script type="text/javascript" src="yass.js"></script>
	<script type="text/javascript" src="sizzle.js"></script>
	<script type="text/javascript" src="Sly.js"></script>
	<script type="text/javascript" src="raze2.js"></script>
	<script type="text/javascript" src="peppy.js"></script>
	<script type="text/javascript" src="ext.js"></script>
	
	
	<script type="text/javascript">
	function runTest(){
		var selectors = [
		         		'table',
		     			'table.a',
		     			'.a',
		     			'table[class]',
		     			'table.a tr',
		     			'table tr.b',
		     			'table tr .c',
		     			'table tr',
		     			'table tr td',
		     			'table.b tr.b td.c',
		     			'.b',
		     			'td:nth-child(2)',
		     			'tr[align=left]',
		     			'tr[align=right]',
		     			'tr[align=left]',
		     			'#trc',
		     			'#trc td',
		     			'#tableb tr td',
		     			'#tableb #trc'];
   		var results={};
   		
   		var engines = [{
	   			name:'raze',
	   			fn:function(selector){return Raze.query(selector,document);}
	   		},{
	    		name:'Ext',
	    		fn:function(selector){return Ext.select(selector,document);}
	    	},{
	   			name:'Sizzle',
	   			fn:function(selector){return Sizzle(selector,document);}
	   		},{
	   			name:'yass',
	   			fn:function(selector){return _(selector,document,false);}
	   		},{
	    		name:'Sly',
	    		fn:function(selector){return Sly.search(selector);}
		    },{
			    name:'Peppy',
			    fn: function(selector){return peppy.query(selector,document);}
			}];

   		//For each selector
   		var res,start,i;

   		for(var s = 0, selector; selector = selectors[s++];){

   			if(!results[selector])results[selector]={};
   			
   			//For each engine
   			for(var e=0, engine;engine=engines[e++];){
   				start = +new Date;
   				//The real test
   				i=500;
   				while(i--){
   					res = engine.fn(selector);
   				}
   				results[selector][engine.name]={time:(+new Date)-start,results:res}; 
   			}
   		}

   		var totals = {};
   		var table = ['<table>'];
   		var out;
   		var selec;
   		var eng;		     		
   		for(var sel in results){
    		table.push('<tr>');

    		table.push('<td>');
    		table.push(sel);
    		table.push('</td>');
    		selec = results[sel];

    		for(var en in selec){
     		if(!totals[en])totals[en] = 0;
    			eng = selec[en];
    			//totals[en] += eng.results.length;
    			totals[en] += eng.time;
     		table.push('<td>');
     		table.push(eng.time)
     		table.push('</td>');
     	}
    		table.push('</tr>');
    	}

   		table.push('<tr><td>TOTALS</td>');

   		for(var e in  totals){
   			table.push('<td>');
   			table.push(e);
   			table.push(': ');
   			table.push(totals[e]);
   			table.push('</td>');
    	}
   		
   		table.push('</tr>');
    	
   		table.push('</table>');

   		document.getElementsByTagName('body')[0].innerHTML = table.join('');
	};
	</script>

</head>
<body>
	<button onclick="runTest();">Roda</button><br/>
	<table class="a">
		<tr class="b">
			<td>bla bla bla bla bla bla bla</td>
		</tr>
		<tr>
			<td class="c">bla bla bla bla bla bla bla</td>
		</tr>
		<tr class="b">
			<td>bla bla bla bla bla bla bla</td>
		</tr>
		<tr class="b">
			<td class="c">bla bla bla bla bla bla bla</td>
		</tr>
	</table>	
	<table class="b" width="100%">
		<tr class="b" align="left">
			<td>bla bla bla bla bla bla bla</td>
		</tr>
		<tr>
			<td class="c">bla bla bla bla bla bla bla</td>
		</tr>
		<tr class="b">
			<td>bla bla bla bla bla bla bla</td>
		</tr>
		<tr class="b">
			<td class="c">bla bla bla bla bla bla bla</td>
		</tr>
	</table>
	<table id="tableb">
		<tr class="b">
			<td>bla bla bla bla bla bla bla</td>
		</tr>
		<tr id="trc">
			<td class="c">bla bla bla bla bla bla bla</td>
		</tr>
		<tr class="b">
			<td>bla bla bla bla bla bla bla</td>
		</tr>
		<tr class="b">
			<td class="c">bla bla bla bla bla bla bla</td>
		</tr>
	</table>
</body>
</html>